<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>{$title}</title>
<link rel="stylesheet" href="/admin/login.css">
</head>
<body>
<!-- begin -->
<div id="login">
    <div class="wrapper">
        <div class="login">
            <form method="post" class="container offset1 loginform">
                <div id="owl-login">
                    <div class="hand"></div>
                    <div class="hand hand-r"></div>
                    <div class="arms">
                        <div class="arm"></div>
                        <div class="arm arm-r"></div>
                    </div>
                </div>
                <div class="pad">
                    <div class="control-group">
                        <div class="controls" style="text-align: center">
                            {$title}
                        </div>
                    </div>
                    <div class="control-group">
                        <div class="controls">
                            <label for="email" class="control-label fa fa-paw"></label>
                            <input id="user_name" autocomplete="off"  type="text" name="user_name" placeholder="请输入登录名，手机号码" tabindex="1" autofocus="autofocus" class="form-control input-medium">
                        </div>
                    </div>
                    <div class="control-group">
                        <div class="controls">
                            <label for="password" class="control-label fa fa-asterisk"></label>
                            <input id="password" autocomplete="off"  type="password" name="password" placeholder="请输入密码" tabindex="2" class="form-control input-medium ">
                        </div>
                    </div>
                </div>
                <div class="form-actions">
                    <button type="button"  id="formDemo" tabindex="4" class="btn btn-primary">Login</button>
                </div>
            </form>
        </div>
    </div>
</div>
<!-- end -->
<script src="/public/jquery-1.12.3.min.js"></script>
<script src="/admin/layui/layui.js"></script>
<script>
    $(function() {
        layui.use(['layer'], function(){
            var layer = layui.layer;
            $("#formDemo").click(function () {
                var data = {user_name:$("#user_name").val(),password:$("#password").val()};
                if(data.user_name && data.password) {
                    var index_login = layer.msg('请求中', {
                        icon: 16
                        ,shade: 0.01,
                        time:0
                    });
                    $.post("/adminLogin", data, function (datas, status) {
                        layer.close(index_login);
                        layer.msg(datas.msg,{
                            success: function(layero, index){
                                if(datas.code == 0){
                                    layer.msg('登陆中...', {
                                        icon: 16
                                        ,shade: 0.01,
                                        time:0
                                    });
                                    window.location.href = datas.url;
                                }
                            }
                        });
                    });
                }else{
                    layer.msg("请填写帐号密码!");
                }
            });
        });
        $('#login #password').focus(function() {
            $('#owl-login').addClass('password');
        }).blur(function() {
            $('#owl-login').removeClass('password');
        });
        $(".loginform").keydown(function(event){
            var keycode = (event.keyCode ? event.keyCode : event.which);
            if(keycode == '13'){
                //回车触发
                $('#formDemo').trigger('click');
            }
        });
    });
</script>
</body>
</html>